package com.hxh.crud.bean;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;

@Data
public class Employee {
    private String empId;

    @Length(min = 1, max = 5)
    private String empName;

    @Email
    private String email;

    @NotEmpty
    private String sex;

    // @NotNull：规定除字符串外其他类型不可为空
    private Integer empStatus;

    // @NotEmpty：规定字符串不可为空
    @NotEmpty
    // @JsonProperty：json解析器可能无法成功解析字段，加上此注解帮助json解析器正确解析字段
    @JsonProperty(value = "dId")
    private String dId;

    private Department department;

    public Employee() {
        super();
    }

    public Employee(String empId, @Length(min = 1, max = 5) String empName, @Email String email, @NotEmpty String sex, Integer empStatus, @NotEmpty String dId, Department department) {
        this.empId = empId;
        this.empName = empName;
        this.email = email;
        this.sex = sex;
        this.empStatus = empStatus;
        this.dId = dId;
        this.department = department;
    }
}